package fr.gadcparis.envieparisienne.model;

import android.location.Location;
import android.util.Log;

public class HitFt extends Hit {
	private static final long serialVersionUID = 1L;
	public HitFt() {
		super();
	}
	public static Hit fromString(String[] header, String string) {
        Hit hit = new HitFt();
        String[] splitted = string.split(",");
        for (int i = 0; i < splitted.length; i++) {
        	Log.i("TOTO", header[i] + ": " + splitted[i]);
        	hit.addMeta(header[i],splitted[i]);
        }
		Location location = new Location("hit"); 
		String[] strLocation = hit.getMeta("Location", "0 0").split(" ");
		if (strLocation[0] != "0") {
			location.setLongitude(Double.parseDouble(strLocation[1]));
			location.setLatitude(Double.parseDouble(strLocation[0]));
	        hit.setLocation(location);
		}		
		return hit;
	}
	public String getEventName() {
		String name =  getMeta("Nom evenement", "None");
		return name;
	}	
	public String getDate() {
		String date =  getMeta("Date", "None");
		return date;
	}		
	public String getAdresse() {
		String location =  getMeta("Location", "None");
		return location;
	}			
	public String getOrganisateur() {
		String organisateur =  getMeta("Organisateur", "None");
		return organisateur;
	}	
	public Boolean getGratuit() {
		boolean bool = true;
		String gratuit =  getMeta("Gratuit", "non");
		gratuit = gratuit.toLowerCase();
		if (gratuit.indexOf("Payant") != -1 )
			bool = false;
		return bool;
	}	
}
